package com.rose.redis._distributed_lock;

import org.redisson.api.RLock;

/**
 * <p>
 * 锁
 * </p>
 *
 * @author: zhu.chen
 * @date: 2020/12/30
 * @version: v1.0.0
 */
public interface Lock {

    /**
     * 加锁
     * 默认时间参考{@link LockConstant}
     *
     * @param lock
     * @return
     * @throws InterruptedException
     */
    boolean tryLock(RLock lock) throws InterruptedException;

    /**
     * 加锁
     *
     * @param lock
     * @param waitTime
     * @param leaseTime
     * @return
     * @throws InterruptedException
     */
    boolean tryLock(RLock lock, Long waitTime, Long leaseTime) throws InterruptedException;

    /**
     * 解锁
     *
     * @param lock
     */
    void unlock(RLock lock);

}
